class Queue:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return self.items == []

    def enqueue(self, item):
        self.items.insert(0,item)

    def dequeue(self):
        return self.items.pop()

    def size(self):
        return len(self.items)
mp=[]
num,w,h=0,0,0
dir=[(0,-1),(-1,0),(0,1),(1,0)]

w,h=map(int,input().split())
st=[0,0]
for i in range(h):
    row=list(input())
    mp.append(row)
    for j in range(len(row)):
        if mp[i][j]=='@':
            st=[i,j]
q=Queue()
q.enqueue(st)
num=1
while not q.isEmpty():
    pt=q.dequeue()
    for i in range(4):
        nr=pt[0]+dir[i][0]
        nc=pt[1]+dir[i][1]
        if 0<=nr<h and 0<=nc<w and mp[nr][nc]=='.':
            num+=1
            q.enqueue([nr,nc])
            mp[nr][nc]='#'
print(num)